package models

import "time"

type User struct {
	ID        uint       `gorm:"primary_key" json:"id"`
	CreatedAt time.Time  `json:"created_at"`
	UpdatedAt time.Time  `json:"updated_at"`
	DeletedAt *time.Time `sql:"index" json:"deleted_at"`
	Name      string     `json:"name"`
	Password  string     `json:"password"`
	Nickname  string     `json:"nickname"`
	Avator    string     `json:"avator"`
	Status    string     `json:"status"`
	RoleName  string     `json:"role_name" sql:"-"`
	RoleId    string     `json:"role_id" sql:"-"`
}

func FindUsers() ([]User, error) {
	var users []User
	err := gormDB.Find(&users).Error
	if err != nil {
		return users, err
	}
	return users, nil
}
